package cn.stylefeng.guns.modular.business.frequency.transport.mapper;

import cn.stylefeng.guns.modular.business.frequency.orderpick.model.param.PickCarExcludeDTO;
import cn.stylefeng.guns.modular.business.frequency.ordersub.model.param.OrderDTO;
import cn.stylefeng.guns.modular.business.frequency.ordersub.model.result.PkgOrderSub;
import cn.stylefeng.guns.modular.business.frequency.ordersub.model.result.PkgOrderSubBase;
import cn.stylefeng.guns.modular.business.frequency.ordersub.model.result.PkgTransportSimple;
import cn.stylefeng.guns.modular.business.frequency.transport.model.param.TransportDTO;
import cn.stylefeng.guns.modular.business.frequency.transport.model.result.*;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.stylefeng.guns.modular.business.frequency.transport.entity.Transport;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * 运单 Mapper 接口
 *
 * @author yujie
 * @date 2023/05/09 17:15
 */
public interface TransportMapper extends BaseMapper<Transport> {

    @Update("update tt_transport set supplier_id = #{companyId} where settlement_id = #{linkmanId}")
    void updateCompanyIdByLinkmanId(@Param("companyId") Long companyId, @Param("linkmanId") Long linkmanId);

    PkgTransportSimple getPkgTransportSimpleById(@Param("id") Long id);


    /** 待发运订单分页列表 */
    Page<PkgOrderSub> getWaitTransportOrderList(@Param("page")Page<Object> defaultPage,@Param("orderDTO") OrderDTO orderDTO);
    Long getWaitTransportOrderNum(@Param("orderDTO") OrderDTO orderDTO);

    List<String> getStartCodes(@Param("orderDTO") OrderDTO orderDTO,@Param("tenantId") Long tenantId);

    List<String> getDestinationCodes(@Param("orderDTO") OrderDTO orderDTO, @Param("tenantId") Long tenantId);


    /** 已发运列表   发运记录 */
    Page<TransportPageVO> getFinishTransportList(@Param("page")Page<Object> defaultPage, @Param("transportDTO") TransportDTO transportDTO,@Param("tenantId") Long tenantId);

    /**签收装车运单列表*/
    Page<TransportPageVO> getSignedTransportList(@Param("page") Page<Object> defaultPage, @Param("transportDTO") TransportDTO transportDTO, @Param("tenantId") Long tenantId);

    /** 发运单详情 */
    PkgTransport getPkgTransportDetail(@Param("id") String id, @Param("scene") Integer scene, @Param("transportDTO") TransportDTO transportDTO, @Param("tenantId") Long tenantId);

    /** 运单详情（按订单展开）*/
    List<TransportExpandVO> getTransportExpandDetail(@Param("id")String id, @Param("transportDTO") TransportDTO transportDTO, @Param("tenantId") Long tenantId);

    TransportVO getTransportVODetail(@Param("transportDTO")TransportDTO transportDTO, @Param("tenantId") Long tenantId);

    Page<PkgOrderSubBase> getWaitTransportExcludeList(@Param("page") Page<Object> defaultPage, @Param("pickCarExcludeDTO") PickCarExcludeDTO pickCarExcludeDTO, @Param("tenantId") Long tenantId);

    @Update("update tt_transport set logistics_status = #{status} where id = #{transportId}")
    void updateLogisticsStatus(@Param("transportId") Long transportId, @Param("status") int status);

    void updateStatusById(@Param("transportId") String transportId, @Param("status") Integer status,
                          @Param("originStatus") Integer originStatus);

    List<PkgWxTransportOrderInfo> getTransportOrderStatusList(@Param("id") String id);

    int countOrderTransportNotInclude(@Param("orderId") Long orderId, @Param("transportId") String transportId);


    String getLineById(@Param("id") Long id);

    List<PkgTransport> getOrderTransportDetail(@Param("orderId") String orderId);

    List<TransportOrderExport> getTransportOrderExport(@Param("id") String id, @Param("tenantId") Long tenantId);


    void updateStatusById(@Param("transportId") Long transportId, @Param("status") Integer status,
            @Param("originStatus") Integer originStatus);
    void updateLogisticsStatusBatchIds(@Param("ids") List<Long> ids);

    List<TransportPageVO> getFinishTransportList2(@Param("transportDTO") TransportDTO transportDTO);
}